package cn.asterly.cicada.web.controller;

import cn.asterly.cicada.common.model.DataTablesResult;
import cn.asterly.cicada.service.impl.ArticleServiceImpl;
import cn.asterly.cicada.service.impl.UserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/panel")
@Api(value = "panel",description = "面板数据")
public class PanelController {
    @Autowired
    public UserServiceImpl userService;

    @Autowired
    public ArticleServiceImpl articleService;

    @RequestMapping(value = "/panelData",method = RequestMethod.GET)
    @ApiOperation(value = "面板数据",httpMethod = "PSOT")
    public DataTablesResult getPanelData(){
        List list=new ArrayList();
        Map<String,Object> map = new HashMap<>();
        map.put("usernumber",userService.selCountUser());
        map.put("essaynumber",articleService.selCountEssays());
        map.put("readmax",articleService.selReadMax());
        list.add(map);
        return new DataTablesResult(true,"主页面板数据",5200,list);
    }


}
